﻿Imports Entidades
Public Class frmBorrarObjetosPorFamilia
    Private lista As List(Of Familia)
    Private Sub frmBorrarObjetosPorFamilia_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        lista = miGestion.obtenerFamilias
        For i As Integer = 0 To lista.Count - 1
            cboFamilias.Items.Add(lista(i).Nombre)
        Next
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If cboFamilias.Text = "" Then
            MessageBox.Show("Selecciona una familia")
            Exit Sub
        End If
        Dim fam As Familia = lista(cboFamilias.SelectedIndex)
        Dim st As String = miGestion.BorrarObjetosPorFamilia(fam)
        If st <> "" Then
            MessageBox.Show(st)
            Exit Sub
        End If
        MessageBox.Show("Se han borrado todos los objetos de la familia " & cboFamilias.Text)
    End Sub
End Class